package app
{
	import app.db.GoRemoteConnection;
	import data.CONST;
	import flash.net.Responder;
	import mx.utils.ObjectUtil;
	
	
	/**
	 * @author thomas fricke
	 * @version 1.0.0
	 * @date 2009-06-11
	 * @desc a GoGrabCategories() connects to the database, grabs all categories
	 * 		to be displayed and adds them to a certain object (in this case to the
	 * 		tabnav-object for the user to sort.
	 **/
	public class GoGrabCategories
	{
		
		[Bindable] public var gateway:GoRemoteConnection;			// gateway file
		[Bindable] public var responder:Responder;					// responder
		[Bindable] public var dataArray:Array;						// contains result
		
		public function setGateway():void {
			gateway = new GoRemoteConnection(CONST.GATEWAY_LOC);
			gateway.call("GoDBHandler.getCatCount", new Responder(onResult, onFault));
		}
		
					
		public function onResult(result:Array):void {
			// gateway.call("GoDBHandler.getCategory", new Responder(onResult2, onFault), String(tabNav.selectedIndex+1));
			// dataArray = result;
			CONST.CAT_OBJECT = result;
			trace("CONST.CAT_OBJECT (GGC): " + ObjectUtil.toString(CONST.CAT_OBJECT));
		}
		
		public function onFault(fault:String):void {
			trace(fault);
		}	
		
		public function GoGrabCategories()
		{
		}

	}
}